﻿using Microsoft.SqlServer.Types;

namespace LsTool
{
    /// <summary>
    /// 地图类
    /// </summary>
    public class MapCom
    {
        /// <summary>
        /// 经纬度两点之间距离换算
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <returns></returns>
        public static double LogLatKm(double x, double y, double x2, double y2)
        {
            var sqlGeography = SqlGeometry.Point(x, y, 0);
          
            var sqlGeography2 = SqlGeometry.Point(x2, y2, 0);
            var stDistance = sqlGeography.STDistance(sqlGeography2);

            return stDistance.Value*111;
        } 
    }
}